<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库管理</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script src="js/page.js"></script>
</head>

<body onload="initialize();">
<jsp:useBean id="database" class="DatabaseConnection.DatabaseConnection" />
<%@include file="connect_database.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String database_name = request.getParameter("database");
String table_name = request.getParameter("table_name").trim();
String sql_check_table = "show tables like '" + table_name + "';";
ResultSet resultset_check_table = database.executeQuery(sql_check_table, database_name);
if (resultset_check_table != null && resultset_check_table.next() == false)
{
%>
<script type="text/javascript">
<!--
	window.location.href = "tables_insert_second.jsp?database=<%= database_name %>&table=<%= table_name %>";
//-->
</script>
<%
}
else if (resultset_check_table == null)
{
%>
<script type="text/javascript">
<!--
	window.alert("连接数据库 <%= database_name %> 失败！");
	window.location.href = "databases.jsp";
//-->
</script>
<%
}
else
{
%>
<script type="text/javascript">
<!--
	window.alert("数据表 <%= table_name %> 已存在！");
	window.history.go(-1);
//-->
</script>
<%
}
if (resultset_check_table != null)
	resultset_check_table.close();
database.closeConnection();
%>
</body>
</html>